Shader "Custom/FanShader"
{
    Properties
    {
        _Color ("Main Color", Color) = (1,1,1,1)
        _Radius ("Radius", Float) = 1.0
        _Angle ("Angle", Float) = 90.0
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 pos : SV_POSITION;
            };

            float4 _Color;
            float _Radius;
            float _Angle;

            v2f vert (appdata v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                float2 uv = i.uv - 0.5;
                float angle = atan2(uv.y, uv.x) * 180.0 / 3.14159265;
                float distance = length(uv);

                if (distance > _Radius || abs(angle) > _Angle / 2.0)
                {
                    discard;
                }

                return _Color;
            }
            ENDCG
        }
    }
    FallBack "Diffuse"
}